package com.anti.modular.bus.billotherrevenues.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.billotherrevenues.entity.BillOtherRevenues;
import com.anti.modular.bus.billotherrevenues.param.BillOtherRevenuesParam;
import com.anti.modular.bus.billotherrevenues.service.BillOtherRevenuesService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 其他收支控制器
 *
 * @author anti
 * @date 2021-06-03 09:34:42
 */
@RestController
@RequestMapping("billOtherRevenues")
public class BillOtherRevenuesController {

    @Resource
    private BillOtherRevenuesService billOtherRevenuesService;

    /**
     * 查询其他收支
     *
     * @author anti
     * @date 2021-06-03 09:34:42
     */
    @GetMapping("page")
    public Result page(PageParam pageParam, BillOtherRevenuesParam billOtherRevenuesParam) {
        return Result.data(billOtherRevenuesService.page(pageParam,billOtherRevenuesParam));
    }

    /**
     * 添加其他收支
     *
     * @author anti
     * @date 2021-06-03 09:34:42
     */
    @PostMapping("add")
    @BusinessLog(title = "其他收支_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BillOtherRevenuesParam.add.class) BillOtherRevenuesParam billOtherRevenuesParam) {
            billOtherRevenuesService.add(billOtherRevenuesParam);
        return Result.success("新增成功");
    }

    /**
     * 删除其他收支
     *
     * @author anti
     * @date 2021-06-03 09:34:42
     */
    @GetMapping("delete/{id}")
    @BusinessLog(title = "其他收支_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@PathVariable(name = "id") Long id) {
            billOtherRevenuesService.delete(id);
        return Result.success("删除成功");
    }


    /**
     * 编辑其他收支
     *
     * @author anti
     * @date 2021-06-03 09:34:42
     */
    @PostMapping("edit")
    @BusinessLog(title = "其他收支_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BillOtherRevenuesParam.edit.class) BillOtherRevenuesParam billOtherRevenuesParam) {
            billOtherRevenuesService.edit(billOtherRevenuesParam);
        return Result.success("修改成功");
    }

    @PostMapping("editDaoZhang")
    @BusinessLog(title = "其他收支_到賬", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result editDaoZhang(@RequestBody @Validated(BillOtherRevenuesParam.editDaoZhang.class) BillOtherRevenuesParam billOtherRevenuesParam) {
            billOtherRevenuesService.editDaoZhang(billOtherRevenuesParam);
        return Result.success("到賬成功");
    }

    /**
     * 查看其他收支
     *
     * @author anti
     * @date 2021-06-03 09:34:42
     */
    @GetMapping("detail")
    public Result detail(@Validated(BillOtherRevenuesParam.detail.class) BillOtherRevenuesParam billOtherRevenuesParam) {
        return Result.data(billOtherRevenuesService.detail(billOtherRevenuesParam));
    }
    @GetMapping("getLookDetail/{id}")
    public Result getLookDetail(@PathVariable(name = "id") Long id) {
        BillOtherRevenues lookDetail = billOtherRevenuesService.getLookDetail(id);
        return Result.data(lookDetail);
    }
    /**
     * 其他收支列表
     *
     * @author anti
     * @date 2021-06-03 09:34:42
     */
    @GetMapping("list")
    public Result list(BillOtherRevenuesParam billOtherRevenuesParam) {
        return Result.data(billOtherRevenuesService.list(billOtherRevenuesParam));
    }
    @GetMapping("getHjBySearchType/{searchType}")
    public Result getHjBySearchType(@PathVariable(name = "searchType") String searchType) {
        return Result.data(billOtherRevenuesService.getHjBySearchType(searchType));
    }
}
